Gebäudedaten aus Preprocessing einlesen

load("output/geom/rolle_bld_out.Rdata")
rolle_bld_out$GAREA<-sapply(rolle_bld_out@polygons,function(x){x@area})
rolle_bld_out$GBAUP<-cut(as.numeric(rolle_bld_out$GBAUJ),breaks=c(0,1919,1945,1960,1970,1980,1985,1990,1995,2000,2005,2010,2015,2500))
test<-rolle_bld_out@data

Diagramme mit Summary Statistic

p1<-ggplot(rolle_bld_out@data, aes(x=sia))+
  geom_bar()+
  theme_minimal()+
  ggtitle(paste("SIA Gebaeudetypen (Anzahl)",sep=""))+
  theme(axis.text.x = element_text(angle = 45, hjust = 1,size=14))+
  xlab("")

p2<-ggplot(rolle_bld_out@data, aes(x=sia,y=GAREA))+
  geom_bar(stat = "identity")+
  theme_minimal()+
  ggtitle(paste("SIA Gebaeudetypen (Flaechensumme)",sep=""))+
  theme(axis.text.x = element_text(angle = 45, hjust = 1,size=14))+
  xlab("")

p.all<-grid.arrange(p1,p2,ncol=1)

p.all
## TableGrob (2 x 1) "arrange": 2 grobs
##   z     cells    name           grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]

SIA Gebäudetypen pro Alterklasse

p1<-ggplot(rolle_bld_out@data, aes(x=sia))+
  geom_bar()+
  facet_wrap(facets = "GBAUP",ncol = 2)+
  theme_bw()+
  ggtitle(paste("SIA Gebaeudetypen (Anzahl)",sep=""))+
  theme(axis.text.x = element_text(angle = 45, hjust = 1,size=14))+
  xlab("")

p2<-ggplot(rolle_bld_out@data, aes(x=sia,y=GAREA))+
  geom_bar(stat = "identity")+
  facet_wrap(facets = "GBAUP",ncol = 2)+
  theme_bw()+
  ggtitle(paste("SIA Gebaeudetypen (Flaechensumme)",sep=""))+
  theme(axis.text.x = element_text(angle = 45, hjust = 1,size=14))+
  xlab("")

p.all2<-grid.arrange(p1,p2,ncol=1)

p.all2
## TableGrob (2 x 1) "arrange": 2 grobs
##   z     cells    name           grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]

Karte mit SIA Gebäudetypen

#erst alle daten in wgs projezieren fuer leaflet projektion
rolle_bld_out.wgs<-spTransform(rolle_bld_out,CRSobj = CRS("+init=epsg:4326"))

pal_sia <- colorFactor(palette="Set3", rolle_bld_out.wgs$sia)
pal_heiz <- colorFactor(palette="Set1", factor(rolle_bld_out.wgs$GHEIZ_text))
pal_energ <- colorFactor(palette="Set1", factor(rolle_bld_out.wgs$GENHZ_text))
pal_alter <- colorFactor(palette="YlOrRd", factor(rolle_bld_out.wgs$GBAUP))


#visualisierung mit leaflet
m <- leaflet() %>%
  
  addProviderTiles(providers$Stamen.TonerLite, group = "OSM (b/w)") %>%
  addProviderTiles(providers$OpenStreetMap, group = "OSM") %>%
  addProviderTiles("Esri.WorldImagery", group = "ESRI") %>%
  
  addPolygons(data=rolle_bld_out.wgs,
              stroke = TRUE,
              fillOpacity = 1, 
              color = ~pal_sia(rolle_bld_out.wgs$sia),
              opacity = 1,
              weight=1,
              fillColor = ~pal_sia(rolle_bld_out.wgs$sia),
              popup=rolle_bld_out.wgs$sia,
              group = "SIA Typen")%>%
    
  addPolygons(data=rolle_bld_out.wgs,
              stroke = TRUE,
              fillOpacity = 1, 
              color = ~pal_heiz(rolle_bld_out.wgs$GHEIZ_text),
              opacity = 1,
              weight=1,
              fillColor = ~pal_heiz(rolle_bld_out.wgs$GHEIZ_text),
              popup=rolle_bld_out.wgs$GHEIZ_text,
              group = "Heizung")%>%
  
    addPolygons(data=rolle_bld_out.wgs,
              stroke = TRUE,
              fillOpacity = 1, 
              color = ~pal_energ(rolle_bld_out.wgs$GENHZ_text),
              opacity = 1,
              weight=1,
              fillColor = ~pal_energ(rolle_bld_out.wgs$GENHZ_text),
              popup=rolle_bld_out.wgs$GENHZ_text,
              group = "Energie")%>%
  
      addPolygons(data=rolle_bld_out.wgs,
              stroke = TRUE,
              fillOpacity = 1, 
              color = ~pal_alter(rolle_bld_out.wgs$GBAUP),
              opacity = 1,
              weight=1,
              fillColor = ~pal_alter(rolle_bld_out.wgs$GBAUP),
              popup=rolle_bld_out.wgs$GBAUP,
              group = "Alter")%>%
  
  addLayersControl(
    baseGroups = c("OSM (b/w)", "OSM","ESRI"),
    overlayGroups = c("SIA Typen","Heizung","Energie","Alter"),
    options = layersControlOptions(collapsed = F)
  )%>%
  hideGroup(c("Heizung","Energie","Alter"))%>%
  addLegend(title = "SIA Typen", pal = pal_sia, values = rolle_bld_out.wgs$sia, opacity = 1,position = "bottomright")%>%
  addLegend(title = "Heizung", pal = pal_heiz, values = rolle_bld_out.wgs$GHEIZ_text, opacity = 1,position = "bottomleft")%>%
  addLegend(title = "Energie", pal = pal_energ, values = rolle_bld_out.wgs$GENHZ_text, opacity = 1,position = "bottomleft")%>%
  addLegend(title = "Alter", pal = pal_alter, values = rolle_bld_out.wgs$GBAUP, opacity = 1,position = "bottomleft")
## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette Set3 is 12
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette Set3 is 12
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette YlOrRd is 9
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette YlOrRd is 9
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette Set3 is 12
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette YlOrRd is 9
## Returning the palette you asked for with that many colors
#leaflet karte ausführen
m

Save all Information

#html karte speichern
wd<-getwd()
htmlwidgets::saveWidget(m, file=paste(wd,"/output/map/mapSia.html",sep=""),selfcontained = T)

ggsave(p.all,filename = "output/viz/buildingPlotSia.png",dpi = 500,width = 22,height = 15)
ggsave(p.all2,filename = "output/viz/buildingPlotSia_age.png",dpi = 500,width = 22,height = 25)